/*
 * @Description:用户信息相关API
 * @Author: wangfuwei
 * @Date: 2020-11-30 18:21:47
 * @LastEditors: wangfuwei
 * @LastEditTime: 2021-04-25 22:49:52
 * @FilePath: /horizon-frontend/src/api/user.js
 */
import request from "@/utils/request";

const actions = {
  Login: "/user/login",
  Logout: "/user/logout",
  UserInfo: "/user/info",
};

/**
 * 用户登录
 *
 * @param {*} parameter
 * {
 *  username:[用户名|String],
 *  password:md5([密码|String])
 * }
 */
export function login(parameter) {
  return request.post(actions.Login, parameter);
}

/**
 * 获取用户信息
 * @returns
 * {
 *    fdId:[ID|String],
 *    usernmae:[用户名|String],
 *    name:[姓名|String],
 *    avatar:[头像|String],
 *    ... ...
 *    meta:{
 *      language:[语言|String],
 *      primaryColor:[主题颜色|String],
 *      colorWeak:[色盲模式|Boolean],
 *      ... ...
 *    }
 * }
 */
export function getInfo() {
  return request.get(actions.UserInfo);
}

/**
 * 退出
 */
export function logout() {
  return request.get(actions.Logout);
}
